require 'config.rb'

#文章からいろいろと学習するよ
def learn(message='')
	return nil if (message=='')
	
	result=Array.new

	case message
	when %r(^\[(.*)\]\[(.*)\])
		time = ["every","morning","afterNoon","teaTime","evening","night"]
		if(time.index($1) != nil) then
			result.push({"table"=>"speak","time"=>$1,"message"=>$2}) if($1!='' and $2!='')
		end
	when %r(「(.*)」には「(.*)」と(返す|返事する))
		result.push({"table"=>"reply","key"=>$1,"value"=>$2}) if($1!='' and $2!='')
	when %r(「(.*)」は「(.*)」と(同じ|同様))
		result.push({"table"=>"trans","key"=>$1,"value"=>$2}) if($1!='' and $2!='')
	when %r(「(.*)」は「(.*)」の(一種|種類|名前))
		result.push({"table"=>"dict","type"=>"updown","key"=>$1,"value"=>$2}) if($1!='' and $2!='')
	when %r(「(.*)」の意味は「(.*)」だよ)
		result.push({"table"=>"dict","type"=>"mean","key"=>$1,"value"=>$2}) if($1!='' and $2!='')
	end

	return result
end
